<?
 $dir = "../";
 include($dir."inc/header.inc.php");

 require("stats-aggreg.inc.php");

 if(file_exists(dirname(__FILE__)."/stats-aggreg.serialized"))
 {
   $statsagg = unserialize(file_get_contents(dirname(__FILE__)."/stats-aggreg.serialized"));
 }
 else
 {
	echo "error, aggregate data has not been computed"; 
 }
 
	$agg = $statsagg->get_aggreg();
?>
<p>Statistics collected from the DNS requests performed against the pool.</p>
	<table class="statslist">
	<tr><th>Date</th><th>A</th><th>AAAA</th><th>SRV</th><th>SUM</th></tr>
	<?
	$gt = array(0,0,0,0);
	foreach($agg as $date => $data)
	{
	$total = $data['A']+$data['AAAA']+$data['SRV'];
	$gt[0] += $data['A'];
	$gt[1] += $data['AAAA'];
	$gt[2] += $data['SRV'];
	$gt[3] += $total;
		echo "<tr><td>{$date}</td><td>{$data['A']}</td><td>{$data['AAAA']}</td><td>{$data['SRV']}</td><td>".($total)."</td></tr>"; 
	}
	?>
	<tr><td><b>Grand total</b></td><td><b><?=$gt[0];?></b></td><td><b><?=$gt[1];?></b></td><td><b><?=$gt[2];?></b></td><td><b><?=$gt[3];?></b></td></tr>	
	</table>
<?
 include($dir."/inc/footer.inc.php");
?>
